package com.example.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.entity.User;
import com.example.mapper.UserMapper;
import com.example.service.UserService;
import com.example.util.MailUtil;
@Service
@Transactional
public class UserServiceImlp implements UserService {
	@Autowired
	private UserMapper userMapper;
	
	private List<User> list;
	
	private User user;
	@Autowired
	private MailUtil mailUtil;



	public int add(User user) {
		int res= userMapper.addUser(user);
		if(res==1){
			String content=String.format("<!DocType html><html><head><meta charset='utf-8'/><title>邮件验证界面</title></head><body>亲爱的:%s,您需要<a href='http://localhost:8080/getUsers/registerUser?uuid=%s'>点击此处</a>进行邮箱验证,谢谢合作</body></html>", new Object[]{user.getUname(),user.getUuid()});
			mailUtil.sendHtmlMail(user.getEmail(),"注册用户的邮箱验证邮件",content);
		}
		return res;
	}

	public int update(User user) {
		return 0;
	}

	public int delete(Integer id) {
		return 0;
	}

}
